<?php
/**
 *	This file is part of rtfdoc.
 *
 *	rtfdoc is free software: you can redistribute it and/or modify
 *	it under the terms of the GNU General Public License as published by
 *	the Free Software Foundation, either version 3 of the License, or
 *	(at your option) any later version.
 *
 *	rtfdoc is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *	GNU General Public License for more details.
 *
 *	You should have received a copy of the GNU General Public License
 *	along with rtfdoc.  If not, see <http://www.gnu.org/licenses/>.
 *
 */
require_once dirname(realpath(__FILE__)) . '/RTFCore.php';
require_once dirname(realpath(__FILE__)) . '/RTFBodyView.php';
// FIXME: i guess this should be called a Paragraph
class RTFBody extends RTFCore
{
    /**
     * holds a collection of text-strings or RTFBody's
     *
     * @var array
     */
    private $texts;
    /**
     * the font to use for this body
     *
     * @var RTFFont
     */
    private $font;
    /**
     * constructs RTFBody object with given text string (which may be formatted)
     * // TODO: link to formatting example
     *
     * @param string $text
     */
    public function __construct($text)
    {
        $this->texts[] = $text;
    }
    /**
     * adds an text-string to output buffer
     *
     * @param string $text
     */
    public function addText($text)
    {
        $this->texts[] = $text;
    }
    /**
     * adds an RTFBody to output buffer
     *
     * @param RTFBody $body
     */
    public function addBody(RTFBody $body)
    {
        $this->texts[] = $body;
    }
    /**
     * sets the font to use for this body
     *
     * @param RTFFont $font
     */
    public function setFont(RTFFont $font)
    {
        $this->font = $font;
    }
    /**
     * returns the parsed RTF string
     *
     * @return string
     */
    public function getRTF()
    {
        $view = new RTFBodyView();
        return $view->parse($this);
    }
    /**
     * return array of texts/RTFBody's
     *
     * @return array
     */
    public function getTexts()
    {
        return $this->texts;
    }
}
?>